package com.leji.song.extra;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Toast;
import com.leji.song.R;
import com.leji.song.util.ActivityStackControlUtil;

public class BaseCoreActivity extends Activity {

	public static final int RIGHT_ENTER_LEFT_EXT = 0; // 从左到右
	
	public ProgressDialog progressDialog;
	
	private Toast toast;
	private int AnimType = -1;


	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		ActivityStackControlUtil.add(this);
		
		switch (AnimType) {
		case RIGHT_ENTER_LEFT_EXT:
			overridePendingTransition(R.anim.anim_right_enter,
					R.anim.anim_left_exit);
			break;

		default:
			break;
		}
		
		progressDialog = new ProgressDialog(this);
		progressDialog.setMessage("加载中，请稍候...");
	}

	public void setAnimType(int type){
		AnimType = type; 
	}
	

	
	public  void showToast(String content) {
		if (toast == null) {
			toast = Toast.makeText(this, content, Toast.LENGTH_SHORT);
		} else {
			toast.setText(content);
		}
		toast.show();
	}
	
	public  void showNetFail() {
		showToast("网络连接错误！");
	}
	
	protected void showActivity(Class<?> cls) {
		Intent intent = new Intent(this, cls);
		startActivity(intent);
	}


	@Override
	public void finish() {
		super.finish();

		switch (AnimType) {
		case RIGHT_ENTER_LEFT_EXT:
			overridePendingTransition(R.anim.anim_left_enter,
					R.anim.anim_right_exit);
			break;

		default:
			break;
		}

	}

}
